const { getTimeDuration } = require('../common/utils');

/**
 * 处理数据为可用数据
 * @param {Array} list 数据列表
 */
export const dealFansListData = (list) => {
    return list.map(item => {
        return {
            fansId: item.userFanId,
            fansName: item.followerUserNickName,
            fansNickName: item.aliasName,
            fansAvatar: item.followerUserPic,
            fansDesc: `${getTimeDuration(item.recentNews, '前')}查看`,
            fansViewCount: item.viewCount,
            fansJoinCount: item.involveActivityCount,
            fansPayCount: `￥${item.payAmount / 100}`,
        };
    })
};

export const dealFollowListData = (list) => {
    return list.map(item => {
        return {
            followId: item.followedObjectId,
            followName: item.followedObjectName,
            followAvatar: item.followedObjectPic,
            followFansCount: item.fansCount,
            followActivityCount: item.activityCount,
        };
    });
};

export const dealEndorsementListData = (list, type = 'brand') => {
    return list.map(item => {
        return type === 'brand' ? {
            brandId: item.brandId,
            name: item.brandName,
            pic: item.brandPic,
            fansCount: item.brandFansCount,
            publishActivityCount: item.brandPublishActivityCount,
        } : {
            storeId: item.storeId,
            name: item.storeName,
            pic: item.storePic,
            fansCount: item.storeFansCount,
            publishActivityCount: item.storePublishActivityCount,
        };
    });
};
